home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tstse13.zip / FLIPONE.S < prev    next >
Text File  |  1994-11-26  |  3KB  |  100 lines

  1. /* Generalized flip for one character for SemWare's TSE editor V2.0.
  2.    Covers also foreign 8-bit IBM characters. To make this SAL macro
  3.    operational, invoke the main menu (F10), choose "Macro", choose
  4.    "Compile" and press Enter at "Execute Macro".
  5.  
  6. ..................................................................
  7. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  8. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  9. Faculty of Accounting & Industrial Management; University of Vaasa
  10. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  11. */
  12.  
  13. // The contents of a simple help, tied later to the CtrlAlt-H key
  14. helpdef tHelpData
  15.   title = "FLIPONE.S HELP"           // The help's caption
  16.   x = 10                             // Location
  17.   y = 3
  18.   // The actual help text
  19.   " Timo's flip. Changes the case of one character "
  20.   " at a time. Converts also the 8-bit foreign"
  21.   " characters. To use, take the cursor where you"
  22.   " wish to start and then keep <CtrlAlt 5> down"
  23.   " as long as you wish to flip. The cursor is"
  24.   " automatically advanced, also from line to line. "
  25.   ""
  26.   " You can use <F11> to invoke the command menu "
  27.   " after first exiting this help. "
  28.   ""
  29.   " Last updated Sat 26-November-1994 20:07:08 "
  30. end  /* tHelpData */
  31.  
  32. // Flip a character, covers also foreign characters
  33. string proc timoReturnFlip (string char)
  34.   string lowercase[40] = 'abcdefghijklmnopqrstuvwxyzåäöüéçæñ'
  35.   string uppercase[40] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖÜÉÇÆÑ'
  36.   string flipped[1]
  37.   integer p1, p2
  38.   p1 = Pos (char, lowercase)
  39.   p2 = Pos (char, uppercase)
  40.   if p1 > 0
  41.     flipped = uppercase[p1]
  42.   elseif p2 > 0
  43.     flipped = lowercase[p2]
  44.   else
  45.     flipped = char
  46.   endif
  47.   return (flipped)
  48. end timoReturnFlip
  49.  
  50. // Flip (chance the case of) a single character
  51. proc timoFlip()
  52.   string char[1] = ''
  53.   PushBlock()
  54.   if MarkStream()
  55.      char = GetMarkedText()
  56.      char = timoReturnFlip(char)
  57.      InsertText(char, _OVERWRITE_)
  58.      if CurrPos() > CurrLineLen()
  59.        NextChar()
  60.      endif
  61.   endif
  62.   PopBlock()
  63. end timoFlip
  64.  
  65. // New keys and menus **************************************************
  66. forward Menu tFlipMenu()
  67. forward proc tDisableNewKeys()
  68.  
  69. // Add the new key definitions
  70. keydef new_keys
  71.   <CtrlAlt 5>      timoFlip()
  72.   <CtrlAlt 0>      tDisableNewKeys()
  73.   <CtrlAlt H>      QuickHelp(tHelpData)
  74.   <F11>            tFlipMenu()
  75. end
  76.  
  77. // Disabling the new extra keys ***************************************
  78. proc tDisableNewKeys()
  79.   if YesNo("Disable the extra keys:") == 1 Disable(new_keys) endif
  80. end
  81.  
  82. // The flip menu ******************************************************
  83. Menu tFlipMenu()
  84.   Title = "Timo's flip menu"
  85.   Width = 19
  86.   x = 40
  87.   y = 3
  88.   history
  89.   "&Flip one character <CtrlAlt 5>" , timoFlip()
  90.   "Administer",,Divide
  91.   "Disable &new keys   <CtrlAlt 0>" , tDisableNewKeys()
  92.   "&Help               <CtrlAlt H>" , QuickHelp(tHelpData)
  93.   "This Menu          <F11>"
  94. end  /* tFlipMenu */
  95.  
  96. proc Main()
  97.   Enable (new_keys)
  98.   tFlipMenu()
  99. end
  100.